// ==UserScript==
// @name         88ys-next-video-btn
// @namespace    http://tampermonkey.net/
// @version      2025-10-05
// @description  try to take over the world!
// @author       You
// @match        https://www.88hd.org/vod-play-id-*-src-*-num-*.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=88hd.org
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    const scriptCode = 'LmjtWboBZ5hUX';
    const floatWindowId = 'floatWindow'+scriptCode;
    const nextVideoBtnId = 'nextVideoBtn'+scriptCode;

    var domStr = '  <button id="'+nextVideoBtnId+'" class="'+nextVideoBtnId+'">下一集</button>';
    // create element such as '<div id="floatWindow" class="floatWindow" style="display: none;">' + domStr + '</div>'
    var newDiv = document.createElement('div');
    newDiv.id = floatWindowId;
    newDiv.className = floatWindowId;
    newDiv.innerHTML = domStr;
    newDiv.style = 'position: fixed;'+
        'z-index: 10;'+
        'top: 100px;'+
        'right: 10px;';
    document.body.appendChild(newDiv);

    var nextVideoBtn = document.getElementById(nextVideoBtnId);
    nextVideoBtn.onclick = function() {
        var url = document.location.href;
        // alert(url);
        var videoNumRe = new RegExp('https?://www.88hd.org/vod-play-id-\\d+-src-\\d+-num-(\\d+)\.html');
        var videoNumMatch = videoNumRe.exec(url);
        if (!videoNumMatch) return false;
        var curVideoNum = videoNumMatch[1];
        // alert(curVideoNum);
        var nextVideoNum = 1+parseInt(curVideoNum);
        var nextVideoUrl = url.replace(curVideoNum+'.html', nextVideoNum+'.html');
        // alert(nextVideoUrl);
        location.href = nextVideoUrl;
    };
})();
